<!DOCTYPE html>
<html>
<head>
    <title>我的信息</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link rel="stylesheet" href="${s.base}/mobile/base/css/weui.min.css">
    <link rel="stylesheet" href="${s.base}/mobile/base/css/jquery-weui.css">
    <link rel="stylesheet" href="${s.base}/mobile/base/css/base.css?123456">
    <link rel="stylesheet" href="${s.base}/mobile/base/css/component.css?123456">
    <style type="text/css">
        body, html {
            background: #ffffff;
        }
    </style>
</head>
<body>
<div class="xyg-comp-form">
    <div class="backgroud1">
        <div class="xyg-comp-form-item-one">
            <div class="xyg-comp-form-item-title">
                微信昵称
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="text" placeholder="请先输入微信昵称" value="${webMember.nickName}" readonly/>
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item-one">
            <div class="xyg-comp-form-item-title">
                手机号
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="number" placeholder="请先输入手机号" id="phone" value="${webMember.phone}" />
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item-one">
            <div class="xyg-comp-form-item-title">
                身份类型
            </div>
            <div class="xyg-comp-form-item-icon">
                <input type="text" placeholder="请先选择身份类型" id="cardType" value="<#if webMember.cardType == '2'>门店经纪人<#else>独立经纪人</#if>" data-values="${webMember.cardType}" readonly/>
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item-one" id="showShopNumber" <#if webMember.cardType == null || webMember.cardType == "" || webMember.cardType == "1">style="display: none"</#if>>
            <div class="xyg-comp-form-item-title">
                门店代码
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="text" placeholder="请先输入门店代码" id="shopNumber" value="${webMember.shopNumber}" />
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item-one">
            <div class="xyg-comp-form-item-title">
                真实姓名
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="text" placeholder="请先输入真实姓名" id="name" value="${webMember.name}" />
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item-one">
            <div class="xyg-comp-form-item-title">
                身份证号
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="text" placeholder="请先输入身份证号" id="idCard" value="${webMember.idCard}" />
            </div>
            <div class="clearBoth"></div>
        </div>
        <div class="xyg-comp-form-item-one">
            <div class="xyg-comp-form-item-title">
                银行卡号
            </div>
            <div class="xyg-comp-form-item-content">
                <input type="text" placeholder="请先输入银行卡号" id="bankNo" value="${webMember.bankNo}" />
            </div>
            <div class="clearBoth"></div>
        </div>
    </div>
    <div class="margT60 width-b-80">
        <div class="xyg-btn-two backgroud4 color2" onclick="submit()" >修改信息</div>
    </div>

</div>

<!--底部菜单开始-->
<div style="width:100%; height:128px;"></div>
<div class="xyg-comp-bottom3">
    <div class="xyg-comp-bottom-item">
        <a href="javascript:goFistPage('${memberId}')">
            <img src="${s.base}/mobile/base/images/icon_menu_1.png"/>
            <div class="xyg-comp-bottom-item-text ">首页</div>
        </a>
    </div>
    <div class="xyg-comp-bottom-item">
        <a href="javascript:goAllCustomerEditPage('${memberId}')">
            <img src="${s.base}/mobile/base/images/icon_menu_2.png"/>
            <div class="xyg-comp-bottom-item-text">推荐</div>
        </a>
    </div>
    <div class="xyg-comp-bottom-item">
        <a href="javascript:goMyPage('${memberId}')">
            <img src="${s.base}/mobile/base/images/icon_menu_3_a.png"/>
            <div class="xyg-comp-bottom-item-text select-text">我的</div>
        </a>
    </div>
    <div class="clearBoth"></div>
</div>
<!--底部菜单结束-->
</body>
<script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<script src="${s.base}/mobile/base/js/jquery-2.1.4.js"></script>
<script src="${s.base}/mobile/base/js/jquery-weui.js"></script>
<script src="${s.base}/mobile/base/js/swiper.js"></script>
<script src="${s.base}/mobile/base/fonts/iconfont.js"></script>
<script src="${s.base}/mobile/base/js/component.js"></script>
<script src="${s.base}/mobile/base/js/base.js?123456789000"></script>
<script type="text/javascript">
    initXygDpi();

    var memberId = '${memberId}';

    $(document).ready(function(e) {
        initDate();
    });

    function initDate() {
        $("#cardType").select({
            title: "请先选择身份类型",
            items:[{
                title: "独立经纪人",
                value: 1
            },{
                title: "门店经纪人",
                value: 2
            }],
            onChange: function(d) {
                if (d.values == 1) {
                    $("#showShopNumber").hide();
                } else if(d.values == 2) {
                    $("#showShopNumber").show();
                }
            }
        });
    }

    function submit() {
        var phone = $("#phone").val();
        if(phone == null || phone == "") {
            $.toast("请输入手机号", "text");
            return false;
        }else if(!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(phone))){
            $.toast("手机码填写错误", "text");
            return false;
        }
        var cardType = $("#cardType").attr("data-values");
        if(cardType == null || cardType == "") {
            $.toast("请选择身份类型", "text");
            return false;
        }
        var shopNumber = $("#shopNumber").val();
        if (cardType == "2") {
            if (shopNumber == null || shopNumber == "") {
                $.toast("请先输入门店代码", "text");
                return false;
            }
        }
        var name = $("#name").val();
        if(name == null || name == "") {
            $.toast("请输入姓名", "text");
            return false;
        }
        var idCard = $("#idCard").val();
        // 身份证正则
        var idCardTest = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
        if (idCard != null && idCard != "" && !idCardTest.test(idCard)) {
            $.toast("身份证填写格式错误", "text");
            return false;
        }
        var bankNo = $("#bankNo").val();
        var bankNoTest = /([\d]{4})([\d]{4})([\d]{4})([\d]{4})([\d]{0,})?/;
        if (bankNo != null && bankNo != "" && !bankNoTest.test(bankNo)) {
            $.toast("银行卡号填写格式错误", "text");
            return false;
        }
        $.fn.postMethodResult("/weChat/memberSaveNotCheckCode",{'id':memberId,'name':name,'cardType':cardType,'phone':phone,'shopNumber':shopNumber,'idCard':idCard,'bankNo':bankNo},function (data) {
            $.alert("操作成功",function () {
                goMyPage(memberId);
            });
        });
    }

    var sendFlage=true;//发送标志，true为可以发送
    function sendSms(){
        if(!sendFlage){
            return false;
        }
        sendFlage=false;
        var phone = $("#phone").val();
        if(phone == null || phone == "") {
            $.toast("请输入手机号", "text");
            sendFlage=true;
            return false;
        }else if(!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(phone))){
            $.toast("手机码填写错误", "text");
            sendFlage=true;
            return false;
        }

        $.fn.postBase("/weChat/smsSend",{'phone':phone},function (result) {
            if (result.code === 0) {
                //操作成功
                $.toast("短信发送成功", "text");
                getRandomCode();
            } else {
                sendFlage=false;
                //操作失败
                $.toast(result.msg, "text");
            }
        });
    }

    var time = 60;
    //倒计时
    function getRandomCode() {
        if (time === 0) {
            time = 60;
            sendFlage=true;
            $('#sendSms').html("获取验证码");
            return;
        } else {
            time--;
            $('#sendSms').html(time+"秒");
        }
        setTimeout(function() {
            getRandomCode();
        },1000);
    }
</script>
</html>
